﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Routing;
using System.Web.Mvc;

using Microsoft.Practices.Unity;

using ERPStore.Extensions;
using ERPStore.Web.Routing;

namespace ERPStore.Exporter.Reporting
{
    public class PluginInit : ERPStore.Extensibility.PluginInit
    {
		public PluginInit()
		{
			Container = GlobalConfiguration.Configuration.DependencyResolver.GetContainer();
		}

		Microsoft.Practices.Unity.IUnityContainer Container { get; set; }

        public override void Load()
        {
        }

        public override void AddServices()
        {
            base.AddServices();

            Container.RegisterType<Services.ReportService>(new ContainerControlledLifetimeManager());
        }

        public override void RegisterRoutes()
        {
            base.RegisterRoutes();

            var namespaces = new string[] { "ERPStore.Exporter.Reporting.Controllers" };

            RouteTable.Routes.MapERPStoreRoute(
                "ExportReport"
                , "export/report/{action}/{id}"
                , new { controller = "Reports", action = "Index", id = UrlParameter.Optional }
                , namespaces
            );

        }
    }
}
